﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected const string connectionString = @"Provider=SQLOLEDB;server=FORMA1614;Database=magicrecettes;User ID=magicrecettes;Password=cook;Trusted_Connection=False";
        protected const string query = "SELECT id_recette,nom,tps_preparation+tps_cuisson as tps_total,cout,difficulte FROM Recette";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                OleDbDataAdapter da = new OleDbDataAdapter(query, connectionString);
                da.TableMappings.Add("Table", "Recette");

                DataSet ds = new DataSet();
                da.Fill(ds);

                Session["RECETTE"] = ds;



                GridView1.DataSource = ds;
                GridView1.DataBind();
            }
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //GridView1.CurrentPageIndex = e.NewPageIndex;
            GridView1.DataSource = (DataSet)Session["RECETTE"];
            GridView1.DataBind();
        }
    }
}